package com.yzpass.api.user.service;

import com.yzpass.api.common.Result;
import com.yzpass.api.common.util.AuthUtil;
import com.yzpass.api.security.UserPermissionService;
import com.yzpass.api.user.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Service
public class ProfileService {
    @Resource
    UserMapper userMapper;

    @Resource
    UserPermissionService userPermissionService;
    public static record MenuPermission(List<String> menuArr, Set<String> permissionArr){}

    public Result<MenuPermission> menu() {
        var userId = AuthUtil.currentUserId();
        if(userId==null){
            return Result.success();
        }

        List<String> menus = userMapper.selectMenus(userId);
        Set<String> permissionArr = userPermissionService.getPemissionSet(userId);

        return Result.success(new MenuPermission(menus,permissionArr));
    }
}
